package day14;

import org.junit.Test;

import java.util.*;

public class Balls {
    public static void main(String[] args) {
        Balls();
    }
    public static void Balls() {
        Scanner sc = new Scanner(System.in);
        Integer[] red = new Integer[6];
        for (int i = 0; i < 6; i++) {
            System.out.print("请输入红色球" +(i+1) + "号码(1~33):");
            int s = sc.nextInt();
            red[i] = s;
        }
        List<Integer> arrayList = Arrays.asList(red);
        LinkedList<Integer> list = new LinkedList<>(arrayList);
        System.out.print("请输入蓝色球的号码：");
        int blue = sc.nextInt();
        list.add(blue);

        //随机双色球
        LinkedList<Integer> list3 = new LinkedList<>();
        Random rd = new Random();
        for (int i = 0; i < 6; i++) {
            int n = rd.nextInt(33) + 1;
            if (list3.contains(n)) ;
            else list3.add(n);
        }
        Collections.sort(list3);
        int n = rd.nextInt(16) + 1;
        list3.addLast(n);

        //比较
        LinkedList<Integer> list4=new LinkedList<>();
        list4.addAll(list);
        if (list4.getLast()==list3.getLast()){
            list4.retainAll(list3);
            int num=list.size();
            switch (num){
                case 5:
                    System.out.println("4个红色球+蓝色球      200元           四等奖");
                    break;
                case 6:
                    System.out.println("5个红色球+蓝色球   5000元             二等级");
                    break;
                case 7:
                    System.out.println("6个红色球+蓝色球   100000元         一等奖");
                    break;
            }
        }else {
            list.retainAll(list3);
            int num=list.size();
            switch (num){
                case 3:
                    System.out.println("3个红色球      10元                          六等奖");
                    break;
                case 4:
                    System.out.println("4个红色球      50元                          五等奖");
                    break;
                case 5:
                    System.out.println("5个红色球      500元                        三等奖");
                    break;
                case 6:
                    System.out.println("6个红色球+蓝色球   100000元         一等奖");
                    break;
            }

        }

    }
}


class Ball{
   static Set<Integer> red=new TreeSet<>();
    //机器生成蓝号
   static Integer blue;

   static Set<Integer> userRed=new TreeSet<>();
   static Integer userBlue;
   static Integer redcount;
   static Integer bluecount;

    public static void main(String[] args) throws InterruptedException {
        Scanner sc = new Scanner(System.in);
        while (userRed.size()!=6){
            System.out.print("请输入红色球号码(1~33):");
            int n= sc.nextInt();
            if (n<1||n>33){
                System.out.println("有重复的号码，请重新输入!");
                continue;
            }
            userRed.add(n);
        }
        while (true){
            System.out.print("请输入蓝号1~16：");
            int n=sc.nextInt();
            if (n<1||n>16){
                System.out.println("输入错误，请重新输入！");
                continue;
            }
            userBlue=n;
            break;
        }
        System.out.println("你投注的红号："+userRed+",你投注的蓝号："+userBlue);
        System.out.println("系统开始生成号码：请稍等...3S");
        for (int i=3;i>0;i--){
            System.out.println("请稍等..."+i+"秒");
            Thread.sleep(1000);
        }
        Random rd=new Random();
        while (red.size()!=6){
            red.add(rd.nextInt(33)+1);
        }
        blue=rd.nextInt(16)+1;
        System.out.println("本次开奖号码红号："+red+",蓝号："+blue);
        //统计结果
        //打印信息
        resultK();
    }
    public static void resultK() throws InterruptedException {
        System.out.println("统计结果...");
        Thread.sleep(1000);
        userRed.retainAll(red);
        redcount=userRed.size();
        if (blue==userBlue) bluecount=1;
        else bluecount=0;
        System.out.println("你中了"+redcount+"个红号，"+bluecount+"个蓝号");
    }
    public static void print(){
        if (redcount==3) System.out.println("3个红色球      10元                          六等奖");
        else if (redcount==4&&bluecount==0) System.out.println("4个红色球      50元                          五等奖");
        else if (redcount==4&&bluecount==1) System.out.println("4个红色球+蓝色球      200元           四等奖");
        else if (redcount==5&&bluecount==0) System.out.println("5个红色球      500元                        三等奖");
        else if (redcount==5&&bluecount==1) System.out.println("5个红色球      10元                          六等奖");
        else if (redcount==6&&bluecount==0) System.out.println("5个红色球+蓝色球   5000元             二等级");
        else if (redcount==6&&bluecount==1) System.out.println("6个红色球+蓝色球   100000元         一等奖");
    }
}